﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Web;

public static class XString
{
    public static String EncodeBase64(this String s)
    {
        byte[] data = Encoding.UTF8.GetBytes(s);
        return Convert.ToBase64String(data);
    }

    public static String DecodeBase64(this String s)
    {
        byte[] data = Convert.FromBase64String(s);
        return Encoding.UTF8.GetString(data);
    }

    public static String EncodeMD5(this String s)
    {
        var md5 = MD5.Create();
        byte[] data = Encoding.UTF8.GetBytes(s);
        var newData = md5.ComputeHash(data);
        return Convert.ToBase64String(newData);
    }
}